<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Index recovery API | ElasticSearch 7.7 权威指南中文版</title>
	<meta name="keywords" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <meta name="description" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <!-- Give IE8 a fighting chance -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
	<link rel="stylesheet" type="text/css" href="../static/styles.css" />
	<script>
	var _link = 'indices-recovery.html';
    </script>
</head>
<body>
<div class="main-container">
    <section id="content">
        <div class="content-wrapper">
            <section id="guide" lang="zh_cn">
                <div class="container">
                    <div class="row">
                        <div class="col-xs-12 col-sm-8 col-md-8 guide-section">
                            <div style="color:gray; word-break: break-all; font-size:12px;">原英文版地址: <a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.7/indices-recovery.html" rel="nofollow" target="_blank">https://www.elastic.co/guide/en/elasticsearch/reference/7.7/indices-recovery.html</a>, 原文档版权归 www.elastic.co 所有<br/>本地英文版地址: <a href="../en/indices-recovery.html" rel="nofollow" target="_blank">../en/indices-recovery.html</a></div>
                        <!-- start body -->
                  <div class="page_header">
<strong>重要</strong>: 此版本不会发布额外的bug修复或文档更新。最新信息请参考 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html" rel="nofollow">当前版本文档</a>。
</div>
<div id="content">
<div class="breadcrumbs">
<span class="breadcrumb-link"><a href="index.html">Elasticsearch Guide [7.7]</a></span>
»
<span class="breadcrumb-link"><a href="rest-apis.html">REST APIs</a></span>
»
<span class="breadcrumb-link"><a href="indices.html">Index APIs</a></span>
»
<span class="breadcrumb-node">Index recovery API</span>
</div>
<div class="navheader">
<span class="prev">
<a href="indices-exists.html">« Index exists API</a>
</span>
<span class="next">
<a href="indices-segments.html">Index segments API »</a>
</span>
</div>
<div class="section">
<div class="titlepage"><div><div>
<h2 class="title">
<a id="indices-recovery"></a>Index recovery API<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/indices/recovery.asciidoc">edit</a>
</h2>
</div></div></div>

<p>Returns information about ongoing and completed shard recoveries.</p>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">GET /twitter/_recovery</pre>
</div>
<div class="console_widget" data-snippet="snippets/1665.console"></div>
<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="index-recovery-api-request"></a>Request<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/indices/recovery.asciidoc">edit</a>
</h3>
</div></div></div>
<p><code class="literal">GET /&lt;index&gt;/_recovery</code></p>
<p><code class="literal">GET /_recovery</code></p>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="index-recovery-api-desc"></a>Description<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/indices/recovery.asciidoc">edit</a>
</h3>
</div></div></div>
<p>Use the index recovery API
to get information about ongoing and completed shard recoveries.</p>
<p>Shard recovery is the process
of syncing a replica shard from a primary shard.
Upon completion,
the replica shard is available for search.</p>
<p>Recovery automatically occurs
during the following processes:</p>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
Node startup or failure.
This type of recovery is called a <span class="strong strong"><strong>local store recovery</strong></span>.
</li>
<li class="listitem">
<a class="xref" href="glossary.html#glossary-replica-shard">Primary shard replication</a>.
</li>
<li class="listitem">
Relocation of a shard to a different node in the same cluster.
</li>
<li class="listitem">
<a href="snapshots-restore-snapshot.html" class="ulink" target="_top">Snapshot restoration</a>.
</li>
</ul>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="index-recovery-api-path-params"></a>Path parameters<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/indices/recovery.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">&lt;index&gt;</code>
</span>
</dt>
<dd>
<p>
(Optional, string) Comma-separated list or wildcard expression of index names
used to limit the request.
</p>
<p>Use a value of <code class="literal">_all</code> to retrieve information for all indices in the cluster.</p>
</dd>
</dl>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="index-recovery-api-query-params"></a>Query parameters<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/indices/recovery.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">active_only</code>
</span>
</dt>
<dd>
(Optional, boolean)
If <code class="literal">true</code>,
the response only includes ongoing shard recoveries.
Defaults to <code class="literal">false</code>.
</dd>
<dt>
<span class="term">
<code class="literal">detailed</code>
</span>
</dt>
<dd>
(Optional, boolean)
If <code class="literal">true</code>,
the response includes detailed information about shard recoveries.
Defaults to <code class="literal">false</code>.
</dd>
<dt>
<span class="term">
<code class="literal">index</code>
</span>
</dt>
<dd>
(Optional, string)
Comma-separated list or wildcard expression of index names
used to limit the request.
</dd>
</dl>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="index-recovery-api-response-body"></a>Response body<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/indices/recovery.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">id</code>
</span>
</dt>
<dd>
(Integer)
ID of the shard.
</dd>
<dt>
<span class="term">
<code class="literal">type</code>
</span>
</dt>
<dd>
<p>(String)
Recovery type.
Returned values include:</p>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">STORE</code>
</span>
</dt>
<dd>
The recovery is related to
a node startup or failure.
This type of recovery is called a local store recovery.
</dd>
<dt>
<span class="term">
<code class="literal">SNAPSHOT</code>
</span>
</dt>
<dd>
The recovery is related to
a <a class="xref" href="snapshots-restore-snapshot.html" title="Restore indices from a snapshot">snapshot restoration</a>.
</dd>
<dt>
<span class="term">
<code class="literal">REPLICA</code>
</span>
</dt>
<dd>
The recovery is related to
a <a class="xref" href="glossary.html#glossary-replica-shard">primary shard replication</a>.
</dd>
<dt>
<span class="term">
<code class="literal">RELOCATING</code>
</span>
</dt>
<dd>
The recovery is related to
the relocation of a shard
to a different node in the same cluster.
</dd>
</dl>
</div>
</dd>
<dt>
<span class="term">
<code class="literal">STAGE</code>
</span>
</dt>
<dd>
<p>(String)
Recovery stage.
Returned values include:</p>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">DONE</code>
</span>
</dt>
<dd>
Complete.
</dd>
<dt>
<span class="term">
<code class="literal">FINALIZE</code>
</span>
</dt>
<dd>
Cleanup.
</dd>
<dt>
<span class="term">
<code class="literal">INDEX</code>
</span>
</dt>
<dd>
Reading index metadata and copying bytes from source to destination.
</dd>
<dt>
<span class="term">
<code class="literal">INIT</code>
</span>
</dt>
<dd>
Recovery has not started.
</dd>
<dt>
<span class="term">
<code class="literal">START</code>
</span>
</dt>
<dd>
Starting the recovery process; opening the index for use.
</dd>
<dt>
<span class="term">
<code class="literal">TRANSLOG</code>
</span>
</dt>
<dd>
Replaying transaction log .
</dd>
</dl>
</div>
</dd>
<dt>
<span class="term">
<code class="literal">primary</code>
</span>
</dt>
<dd>
(Boolean)
If <code class="literal">true</code>,
the shard is a primary shard.
</dd>
<dt>
<span class="term">
<code class="literal">start_time</code>
</span>
</dt>
<dd>
(String)
Timestamp of recovery start.
</dd>
<dt>
<span class="term">
<code class="literal">stop_time</code>
</span>
</dt>
<dd>
(String)
Timestamp of recovery finish.
</dd>
<dt>
<span class="term">
<code class="literal">total_time_in_millis</code>
</span>
</dt>
<dd>
(String)
Total time to recover shard in milliseconds.
</dd>
<dt>
<span class="term">
<code class="literal">source</code>
</span>
</dt>
<dd>
<p>(Object)
Recovery source.
This can include:</p>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
A repository description if recovery is from a snapshot
</li>
<li class="listitem">
A description of source node
</li>
</ul>
</div>
</dd>
<dt>
<span class="term">
<code class="literal">target</code>
</span>
</dt>
<dd>
(Object)
Destination node.
</dd>
<dt>
<span class="term">
<code class="literal">index</code>
</span>
</dt>
<dd>
(Object)
Statistics about physical index recovery.
</dd>
<dt>
<span class="term">
<code class="literal">translog</code>
</span>
</dt>
<dd>
(Object)
Statistics about translog recovery.
</dd>
<dt>
<span class="term">
<code class="literal">start</code>
</span>
</dt>
<dd>
(Object)
Statistics about time to open and start the index.
</dd>
</dl>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="index-recovery-api-example"></a>Examples<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/indices/recovery.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="section">
<div class="titlepage"><div><div>
<h4 class="title">
<a id="index-recovery-api-multi-ex"></a>Get recovery information for several indices<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/indices/recovery.asciidoc">edit</a>
</h4>
</div></div></div>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">GET index1,index2/_recovery?human</pre>
</div>
<div class="console_widget" data-snippet="snippets/1666.console"></div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h4 class="title">
<a id="index-recovery-api-all-ex"></a>Get segment information for all indices<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/indices/recovery.asciidoc">edit</a>
</h4>
</div></div></div>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">GET /_recovery?human</pre>
</div>
<div class="console_widget" data-snippet="snippets/1667.console"></div>
<p>The API returns the following response:</p>
<div class="pre_wrapper lang-console-result">
<pre class="programlisting prettyprint lang-console-result">{
  "index1" : {
    "shards" : [ {
      "id" : 0,
      "type" : "SNAPSHOT",
      "stage" : "INDEX",
      "primary" : true,
      "start_time" : "2014-02-24T12:15:59.716",
      "start_time_in_millis": 1393244159716,
      "stop_time" : "0s",
      "stop_time_in_millis" : 0,
      "total_time" : "2.9m",
      "total_time_in_millis" : 175576,
      "source" : {
        "repository" : "my_repository",
        "snapshot" : "my_snapshot",
        "index" : "index1",
        "version" : "{version}",
        "restoreUUID": "PDh1ZAOaRbiGIVtCvZOMww"
      },
      "target" : {
        "id" : "ryqJ5lO5S4-lSFbGntkEkg",
        "host" : "my.fqdn",
        "transport_address" : "my.fqdn",
        "ip" : "10.0.1.7",
        "name" : "my_es_node"
      },
      "index" : {
        "size" : {
          "total" : "75.4mb",
          "total_in_bytes" : 79063092,
          "reused" : "0b",
          "reused_in_bytes" : 0,
          "recovered" : "65.7mb",
          "recovered_in_bytes" : 68891939,
          "percent" : "87.1%"
        },
        "files" : {
          "total" : 73,
          "reused" : 0,
          "recovered" : 69,
          "percent" : "94.5%"
        },
        "total_time" : "0s",
        "total_time_in_millis" : 0,
        "source_throttle_time" : "0s",
        "source_throttle_time_in_millis" : 0,
        "target_throttle_time" : "0s",
        "target_throttle_time_in_millis" : 0
      },
      "translog" : {
        "recovered" : 0,
        "total" : 0,
        "percent" : "100.0%",
        "total_on_start" : 0,
        "total_time" : "0s",
        "total_time_in_millis" : 0,
      },
      "verify_index" : {
        "check_index_time" : "0s",
        "check_index_time_in_millis" : 0,
        "total_time" : "0s",
        "total_time_in_millis" : 0
      }
    } ]
  }
}</pre>
</div>
<p>This response includes information
about a single index recovering a single shard.
The source of the recovery is a snapshot repository
and the target of the recovery is the <code class="literal">my_es_node</code> node.</p>
<p>The response also includes the number
and percentage of files and bytes recovered.</p>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h4 class="title">
<a id="index-recovery-api-detailed-ex"></a>Get detailed recovery information<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/indices/recovery.asciidoc">edit</a>
</h4>
</div></div></div>
<p>To get a list of physical files in recovery,
set the <code class="literal">detailed</code> query parameter to <code class="literal">true</code>.</p>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">GET _recovery?human&amp;detailed=true</pre>
</div>
<div class="console_widget" data-snippet="snippets/1668.console"></div>
<p>The API returns the following response:</p>
<div class="pre_wrapper lang-console-result">
<pre class="programlisting prettyprint lang-console-result">{
  "index1" : {
    "shards" : [ {
      "id" : 0,
      "type" : "STORE",
      "stage" : "DONE",
      "primary" : true,
      "start_time" : "2014-02-24T12:38:06.349",
      "start_time_in_millis" : "1393245486349",
      "stop_time" : "2014-02-24T12:38:08.464",
      "stop_time_in_millis" : "1393245488464",
      "total_time" : "2.1s",
      "total_time_in_millis" : 2115,
      "source" : {
        "id" : "RGMdRc-yQWWKIBM4DGvwqQ",
        "host" : "my.fqdn",
        "transport_address" : "my.fqdn",
        "ip" : "10.0.1.7",
        "name" : "my_es_node"
      },
      "target" : {
        "id" : "RGMdRc-yQWWKIBM4DGvwqQ",
        "host" : "my.fqdn",
        "transport_address" : "my.fqdn",
        "ip" : "10.0.1.7",
        "name" : "my_es_node"
      },
      "index" : {
        "size" : {
          "total" : "24.7mb",
          "total_in_bytes" : 26001617,
          "reused" : "24.7mb",
          "reused_in_bytes" : 26001617,
          "recovered" : "0b",
          "recovered_in_bytes" : 0,
          "percent" : "100.0%"
        },
        "files" : {
          "total" : 26,
          "reused" : 26,
          "recovered" : 0,
          "percent" : "100.0%",
          "details" : [ {
            "name" : "segments.gen",
            "length" : 20,
            "recovered" : 20
          }, {
            "name" : "_0.cfs",
            "length" : 135306,
            "recovered" : 135306
          }, {
            "name" : "segments_2",
            "length" : 251,
            "recovered" : 251
          }
          ]
        },
        "total_time" : "2ms",
        "total_time_in_millis" : 2,
        "source_throttle_time" : "0s",
        "source_throttle_time_in_millis" : 0,
        "target_throttle_time" : "0s",
        "target_throttle_time_in_millis" : 0
      },
      "translog" : {
        "recovered" : 71,
        "total" : 0,
        "percent" : "100.0%",
        "total_on_start" : 0,
        "total_time" : "2.0s",
        "total_time_in_millis" : 2025
      },
      "verify_index" : {
        "check_index_time" : 0,
        "check_index_time_in_millis" : 0,
        "total_time" : "88ms",
        "total_time_in_millis" : 88
      }
    } ]
  }
}</pre>
</div>
<p>The response includes a listing
of any physical files recovered
and their sizes.</p>
<p>The response also includes timings in milliseconds
of the various stages of recovery:</p>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
Index retrieval
</li>
<li class="listitem">
Translog replay
</li>
<li class="listitem">
Index start time
</li>
</ul>
</div>
<p>This response indicates the recovery is <code class="literal">done</code>.
All recoveries,
whether ongoing or complete,
are kept in the cluster state
and may be reported on at any time.</p>
<p>To only return information about ongoing recoveries,
set the <code class="literal">active_only</code> query parameter to <code class="literal">true</code>.</p>
</div>

</div>

</div>
<div class="navfooter">
<span class="prev">
<a href="indices-exists.html">« Index exists API</a>
</span>
<span class="next">
<a href="indices-segments.html">Index segments API »</a>
</span>
</div>
</div>

                  <!-- end body -->
                        </div>
                        <div class="col-xs-12 col-sm-4 col-md-4" id="right_col">
                        
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </section>
</div>
<script src="../static/cn.js"></script>
</body>
</html>